var user_data = {};

function background_main()
{
  debug("Background Thread started");
  chrome.browserAction.onClicked.addListener(openLoginTab);
  chrome.omnibox.onInputCancelled.addListener(omniboxCancel);
  chrome.omnibox.onInputChanged.addListener(omniboxInputChanged);
  chrome.omnibox.onInputEntered.addListener(omniboxInput);
  chrome.omnibox.onInputStarted.addListener(omniboxInputStarted);
}

function openLoginTab() 
{
  debug("Popup clicked, opening new tab.");
	chrome.tabs.create({url: "src/html/login.html", pinned: true});
}

function saveUserData(userDataObj)
{
  debug("Data saved for tab id:"+userDataObj.tabId);
  user_data[userDataObj.tabId] = userDataObj;
}

function getUserDataForTab(tabId)
{
  var userData = user_data[tabId];

  if(!userData)
    throw("No user data found for tab:"+tabId);

  return userData;
}

function omniboxCancel()
{

}

function omniboxInput(str)
{

}

function omniboxInputChanged(str, suggest)
{
  debug("Omni:"+str);
}

function omniboxInputStarted()
{

}
